<?php

	require_once('../inc/fen_fns.php');
	
	sec_session_start();
	$uid = $_GET['uid'];
	
	if (isset($uid)) {
		$formtype = "modify";
	} else {
		$formtype = "add";
	}
	
	$uid = substr($_GET['uid'],2);
	
	if (login_check($mysqli, '>', '10') == true) {
		
		$query = $_DB->Query("SELECT
							fen_publications.id as publication_id,
							fen_publications.member_id as publication_member_id,
							fen_publications.yayin_tipi,
							fen_publications.tesvik,
							fen_publications.yayin_turu,
							fen_publications.eser_adi,
							fen_publications.dergi_adi,
							fen_publications.volume,
							fen_publications.issue,
							fen_publications.sayfa,
							fen_publications.yayinevi_adi,
							fen_publications.doi_no,
							fen_publications.yayin_yili,
							fen_publications.yazar_sayisi,
							fen_publications.indeks_turu,
							fen_publications.indeks_alan,
							fen_publications.sinif,
							fen_publications.kitap_adi,
							fen_publications.editor_adi,
							fen_publications.isbn_no
							from fen_publications, fen_members
							WHERE
							fen_publications.member_id = fen_members.id and
							fen_publications.id = '$uid' and
							fen_members.username = '".$_SESSION['username']."'");
		$count = $_DB->GetResultNumber($query);
		
		$publication_id = $_DB->GetResultValue($query, "0", "publication_id");
		$member_id = $_DB->GetResultValue($query, "0", "publication_member_id");
		$tesvik = $_DB->GetResultValue($query, "0", "tesvik");
		$yayin_tipi = $_DB->GetResultValue($query, "0", "yayin_tipi");
		$yayin_turu = $_DB->GetResultValue($query, "0", "yayin_turu");
		$eser_adi = $_DB->GetResultValue($query, "0", "eser_adi");
		$dergi_adi = $_DB->GetResultValue($query, "0", "dergi_adi");
		$volume = $_DB->GetResultValue($query, "0", "volume");
		$issue = $_DB->GetResultValue($query, "0", "issue");
		$sayfa = $_DB->GetResultValue($query, "0", "sayfa");
		$yayinevi_adi = $_DB->GetResultValue($query, "0", "yayinevi_adi");
		$doi_no = $_DB->GetResultValue($query, "0", "doi_no");
		$yayin_yili = $_DB->GetResultValue($query, "0", "yayin_yili");
		$yazar_sayisi = $_DB->GetResultValue($query, "0", "yazar_sayisi");
		$indeks_turu = $_DB->GetResultValue($query, "0", "indeks_turu");
		$indeks_alan = $_DB->GetResultValue($query, "0", "indeks_alan");
		$sinif = $_DB->GetResultValue($query, "0", "sinif");
		$kitap_adi = $_DB->GetResultValue($query, "0", "kitap_adi");
		$editor_adi = $_DB->GetResultValue($query, "0", "editor_adi");
		$isbn_no = $_DB->GetResultValue($query, "0", "isbn_no");

?>

<p class="contentMainP">Yayın Bilgileri</p>
			<hr noshade>
			
			<form name="input" action="<?php echo $formtype; ?>.php" method="post">
			
			<label for="form1">Yayın Tipi:</label>
			<select class="selectShort" type="text" onChange="return setForm(this);" name="yayin_tipi" id="yayin_tipi" <?php if (strlen($yayin_tipi) > 1) { echo "disabled"; } ?>>
				<option value="Makale" <?php if ($yayin_tipi == "Makale") { echo "selected"; } ?>>Makale</option>
				<option value="Kitap Bölümü" <?php if ($yayin_tipi == "Kitap Bölümü") { echo "selected"; } ?>>Kitap Bölümü</option>
				<option value="Kitap" <?php if ($yayin_tipi == "Kitap") { echo "selected"; } ?>>Kitap</option>
			</select><font color="#ff9600"> *</color>
			<script type="text/javascript">	var yayin_tipi = new LiveValidation('yayin_tipi'); yayin_tipi.add( Validate.Presence );</script><br>
			
			<label for="form1">Yayın Türü:</label>
			<p id="radiop"><input id="radio" type="radio" name="yayin_turu" value="Ulusal"  <?php if (($yayin_turu == "Ulusal") || ($yayin_turu != "Ulusal" && $yayin_turu != "Uluslararası")) { echo "checked"; } ?>>Ulusal <input id="radio" type="radio" name="yayin_turu" value="Uluslararası"  <?php if ($yayin_turu == "Uluslararası") { echo "checked"; } ?>>Uluslararası</p>
			<label for="form1">Yayın Yılı:</label>
			<select class="selectShort" type="text" id="yayin_yili" name="yayin_yili" >
				<option value="" selected>Seçiniz</option>
				<?php
				
				for ($i=0; $i<14; $i++) {
					$year = 2014 - $i;
					
					$yearselected = ""; if ($yayin_yili == $year) { $yearselected = "selected"; }
					echo "<option value=\"".$year."\" ".$yearselected.">".$year."</option>";
				}
				
				?>		
			</select><font color="#ff9600"> *</color>
			<script type="text/javascript">	var yayin_yili = new LiveValidation('yayin_yili'); yayin_yili.add( Validate.Presence );</script><br>
			
			<label for="form1">Yazar Sayısı:</label>
			<select class="selectShort" type="text" id="yazar_sayisi" name="yazar_sayisi">
				<option value="" selected>Seçiniz</option>
				<?php
				
				for ($i=0; $i<50; $i++) {
					$yazar = 1 + $i;
					
					$yazarselected = ""; if ($yazar_sayisi == $yazar) { $yazarselected = "selected"; }
					echo "<option value=\"".$yazar."\" ".$yazarselected.">".$yazar."</option>";
				}
				
				?>		
			</select><font color="#ff9600"> *</color>
			<script type="text/javascript">	var yazar_sayisi = new LiveValidation('yazar_sayisi'); yazar_sayisi.add( Validate.Presence );</script><br>
			
			<label for="form1">Eserin Adı:</label> <input type="text" id="eser_adi" name="eser_adi" value="<?php echo $eser_adi; ?>"><font color="#ff9600"> *</color>
			<script type="text/javascript">	var eser_adi = new LiveValidation('eser_adi'); eser_adi.add( Validate.Presence );</script><br>
			
			<div id="formkitapadi">
				<label for="form1">Kitap Adı:</label> <input type="text" id="kitap_adi" name="kitap_adi" value="<?php echo $kitap_adi; ?>"><br>
			</div>
			<div id="formeditoradi">
				<label for="form1">Editör Adı:</label> <input type="text" id="editor_adi" name="editor_adi" value="<?php echo $editor_adi; ?>"><br>
			</div>
			<div id="formisbn">
				<label for="form1">ISBN No:</label> <input type="text" id="isbn_no" name="isbn_no" value="<?php echo $isbn_no; ?>"><br>
			</div>
			
			<div id="formmakale">
				<label for="form1">Dergi Adı:</label> <input type="text" id="dergi_adi" name="dergi_adi" value="<?php echo $dergi_adi; ?>"><br>
				
				<label for="form1">DOİ / Web:</label>
				<select class="selectShort4" type="text" id="doiweb" name="doiweb" onChange="return setDoiweb(this);">
					<option value="" selected>Seçiniz</option>
					<option value="doi" <?php if ($doi_no[0] == "1") { echo "selected"; } ?>>DOİ</option>
					<option value="web" <?php if ($doi_no[0] == "h" || $doi_no[0] == "w") { echo "selected"; } ?>>Web Adresi</option>
				</select><br>
				
				<div id="formdoihead" <?php if (($doi_no[0] == "h" || $doi_no[0] == "w") || strlen($doi_no) < 1) { echo "style=\"display: none;\""; } ?>>
					<label for="form1">DOİ No:</label>
				</div>
				<div id="formwebhead" <?php if (($doi_no[0] == "1") || strlen($doi_no) < 1)   { echo "style=\"display: none;\""; } ?>>
					<label for="form1">Web Adresi:</label>
				</div>
				<div id="formdoi" <?php if (strlen($doi_no) < 1)   { echo "style=\"display: none;\""; } ?>>
					<input type="text" id="doi_no" name="doi_no" value="<?php echo $doi_no; ?>">
					<font color="333333">Örnek: 10.1016/j.porgcoat.2011.02.001</font><br>	
				</div>
			
				<label for="form1">Volume:</label> <input type="text" id="volume" name="volume" value="<?php echo $volume; ?>"><br>
			
				<label for="form1">Issue:</label> <input type="text" id="issue" name="issue" value="<?php echo $issue; ?>"><br>	
				
				<label for="form1">İndeks Türü:</label>
				<select class="selectShort4" type="text" id="indeks_turu" name="indeks_turu" onChange="return setIndeksAlan(this);">
					<option value="" selected>Seçiniz</option>
					<option value="SCI" <?php if ($indeks_turu == "SCI") { echo "selected"; } ?>>SCI</option>
					<option value="SCIE" <?php if ($indeks_turu == "SCIE") { echo "selected"; } ?>>SCIE</option>
					<option value="SSCI" <?php if ($indeks_turu == "SSCI") { echo "selected"; } ?>>SSCI</option>
					<option value="AHCI" <?php if ($indeks_turu == "AHCI") { echo "selected"; } ?>>AHCI</option>
					<option value="Alan" <?php if ($indeks_turu == "Alan") { echo "selected"; } ?>>Alan</option>
				</select><br>
				
				<div id="indeks_alan_div" <?php if ($indeks_turu != "Alan") { echo "style=\"display: none;\""; } ?>>
					<label for="form1">İndeks Alan:</label> <input type="text" id="indeks_alan" name="indeks_alan" value="<?php echo $indeks_alan; ?>"><br>
				</div>
				
				<label for="form1">Dergi Grubu:</label>
				<select class="selectShort4" type="text" id="sinif" name="sinif">
					<option value="" selected>Seçiniz</option>
					<option value="A" <?php if ($sinif == "A") { echo "selected"; } ?>>A</option>
					<option value="B" <?php if ($sinif == "B") { echo "selected"; } ?>>B</option>
					<option value="C" <?php if ($sinif == "C") { echo "selected"; } ?>>C</option>
					<option value="D" <?php if ($sinif == "D") { echo "selected"; } ?>>D</option>
				</select><br>
			</div>
			
			<div id="formsayfa">
				<label for="form1">Sayfa:</label> <input type="text" id="sayfa" name="sayfa" value="<?php echo $sayfa; ?>"><font color="333333"> Örnek: 125-132</font>
				<br>
			</div>
			
			<label for="form1">Yayınevi Adı:</label> <input type="text" id="yayinevi_adi" name="yayinevi_adi" value="<?php echo $yayinevi_adi; ?>">
			<br>
			
			<label for="form1">Teşvik Başvurusu:</label>
			<select class="selectShort4" type="text" id="tesvik" name="tesvik" <?php if ($tesvik == '0' || $tesvik == '1') { echo "disabled"; } ?>>
				<option value="" selected>Seçiniz</option>
				<option value="1" <?php if ($tesvik == "1") { echo "selected"; } ?>>Evet</option>
				<option value="0" <?php if ($tesvik == "0") { echo "selected"; } ?>>Hayır</option>
			</select><font color="#ff9600"> *</color>
			<script type="text/javascript">	var tesvik = new LiveValidation('tesvik'); tesvik.add( Validate.Presence );</script><br>

			<br>
			
			<script type="text/javascript">
			$(document).ready(function() {
			    $('.buttonClose2').click(function(){
			        $(".contentTopArea").slideToggle(150);
			    }); 
   			 });
			</script>
			
			<input id="buttonSaveNew" type="submit" value="Kaydet"><a class="buttonClose2" id="buttonClose2">Kapat</a><br><br>
			<input type="hidden" name="publication_id" value="<?php echo $publication_id; ?>">
			</form>
			
<?php 

} else {

	header('Location: ../index.php?error=2');
	
}

?>